<!DOCTYPE html>
<html>

<head>
    <#include "/xhc/admin/components/meta.html" />
    <title>出出帮火车奇妙世界后台 ${metaTitleSuffix!}</title>
    <#include "/xhc/admin/components/stylesheets.html" />
</head>

<body>
    <div id='app'>
        <el-container>
            <#assign menuIndex="2-2" />
            <#include "/xhc/admin/components/menu.html" />
            <el-container>
                <#include "/xhc/admin/components/header.html" />
                <el-main>
                    <template>
                        <el-date-picker v-model="date" type="datetimerange" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="yyyy-MM-dd HH:mm:ss" @change="onDateChange" unlink-panels="true">
                        </el-date-picker>
                        <el-table :data="items" style="width: 100%">
                            <el-table-column prop="addTime" label="下单时间">
                            </el-table-column>
                            <el-table-column prop="no" label="订单号">
                            </el-table-column>
                            <el-table-column prop="title" label="商品">
                            </el-table-column>
                            <el-table-column prop="nickName" label="微信">
                            </el-table-column>
                            <el-table-column prop="userName" label="姓名">
                            </el-table-column>
                            <el-table-column prop="telNumber" label="电话">
                            </el-table-column>
                            <el-table-column prop="address" label="地址">
                            </el-table-column>
                            <el-table-column prop="status" label="状态">
                                <template slot-scope="scope">
                                    <span v-if='scope.row.status ==-1'>已退款</span>
                                    <span v-if='scope.row.status ==0'>未支付</span>
                                    <span v-if='scope.row.status ==1'>已支付</span>
                                </template>
                            </el-table-column>
                            <el-table-column prop="trackNo" label="物流号">
                            </el-table-column>
                            <el-table-column prop="isUsed" label="操作">
                                <template slot-scope="scope">
                                    <!-- <el-button size='small' @click=onUpdateOrder(scope.row)>更新</el-button> -->
                                    <!-- <el-button v-if='scope.row.status ==1' size='small' @click=onRefund(scope.row)> 退款</el-button> -->
                                    <el-button @click='onEditTrackNo(scope.row)' size='small'>物流号</el-button>
                                </template>
                            </el-table-column>
                        </el-table>
                        <#include '/components/page.html' />
                    </template>
                </el-main>
            </el-container>
        </el-container>
        <#include "/xhc/admin/components/footer.html" />
    </div>
    <#include "/xhc/admin/components/scripts.html" />
    <script type="text/javascript">
    var vue = new Vue({
        el: '#app',
        data() {
            return {
                date: ['${startDate!}', '${endDate!}'],
                items: JSON.parse(`${items![]}`)
            }
        },
        mounted: function() {},
        methods: {
            onEditTrackNo(info) {
                vue.$prompt('请输入快递号', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                }).then(({ value }) => {
                    if (value == '') {
                        return
                    }
                    var param = {
                        trackNo: value,
                        id: info.id
                    }
                    axiosRequest(param, '/xhc/web/order/updateTrackNo', '')
                }).catch(() => {});
            },
            onRefund(info) {
                this.$confirm('确定退款?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    var param = {
                        id: info.id
                    }
                    axiosRequest(param, '/xhc/web/order/refundPresent', '')
                }).catch(() => {});
            },
            onUpdateOrder(info) {
                var param = {
                    orderId: info.orderId
                }
                axiosRequest(param, '/xhc/web/order/updateOrder', '')
            },
            onDateChange(val) {
                var keys = [
                    { key: 'startDate', value: val[0] },
                    { key: 'endDate', value: val[1] }
                ]
                goPage(1, keys)
            },
        },
        filters: {
            fmt(date) {
                return date
            }
        }
    })
    </script>
    <script>
    // vue.tableData = ${items!};
    </script>
</body>

</html>